package com.sxbbc.api.controller;

import com.function.common.GetRest;
import com.function.common.RestResponse;
import com.sxbbc.api.common.ActivityMapping;
import com.sxbbc.common.basics.utils.statics.StaticUtils;
import com.sxbbc.common.core.entity.jz.AppBanner;
import com.sxbbc.common.core.enums.BannerPositionEnums;
import com.sxbbc.common.core.service.IAppBannerService;
import com.sxbbc.common.core.service.system.solr.SolrproductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 积分商城 控制层
 *
 * @author leehao
 * @date 2019-06-04 10:53
 */
@RestController

public class PointController {

    @Autowired
    private IAppBannerService appBannerService;
    @Autowired
    private SolrproductService solrproductService;

    /**
     * banner图集合
     * @author leehao
     * @return com.function.common.RestResponse
     */
    @RequestMapping(value = ActivityMapping.SHOW_POINT_BANNER)
    public RestResponse showPointBannerList(){
        //banner集合
        AppBanner banner = new AppBanner();
        banner.setPosition(StaticUtils.ICON_POSITION_APP);
        banner.setType(BannerPositionEnums.POINT.getId());
        List<AppBanner> bannerList = appBannerService.queryBannerListForApi(banner);
        return GetRest.getSuccess("success",bannerList);
    }

//    /**
//     * 积分商城列表
//     * @param cpage 页码 默认1
//     * @param search 搜索
//     *               sort=4 sortDesc=desc 价格排序高在前 sortDesc=asc 价格排序低在前
//     *               sort=3 新品
//     *               sort=2 销量
//     *               sort不传默认或综合
//     * @author leehao
//     * @return com.function.common.RestResponse
//     */
//    @GetMapping(value = ActivityMapping.SHOW_POINT_PRODUCT)
//    public RestResponse showPointProductList(@RequestParam(defaultValue = "1") Integer cpage, SearchVo search){
//        if (CalcuUtils.getInstance().isEquals(search.getSortType(),SolrSortEnums.PRICE.getId())) {
//            search.setSortDesc("asc");
//        }
//        SolrProductDto solrProductDto = new SolrProductDto();
//        solrProductDto.setType(ProductTypeEnums.POINT.getId());
//        if (StringUtils.isNotBlank(search.getKey())) {
//            solrProductDto.setPname(search.getKey());
//        }
//        Solrpage<SolrProductDto> solrPage = solrproductService.queryProduct(solrProductDto,
//                search.getSortType(), search.getSortDesc(), cpage);
//        return GetRest.getSuccess("success",solrPage);
//    }
}
